package Interface.Hoteleria;

import LN.Alquileres.Habitacion;
import LN.Alquileres.Hospedaje_Habitacion;
import LN.Varios.Hosteria;
import java.awt.Color;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.sql.SQLException;
import java.util.Calendar;
import java.util.Date;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.SwingUtilities;

public class Vista_Diario extends javax.swing.JPanel {

    private Hosteria unaHosteria;
    private JButton ultimoBoton;
    java.sql.Connection con;

    @SuppressWarnings("empty-statement")
    public Vista_Diario(final Hosteria unaHosteria) {
        this.unaHosteria = unaHosteria;
        this.ultimoBoton = null;
        initComponents();

        verificarEstados();

        final JPopupMenu popup = new JPopupMenu();
        final JMenuItem m1 = new JMenuItem(" Alquilar");
        JMenuItem m2 = new JMenuItem("Modificar");
        m1.setIcon(new ImageIcon(getClass().getResource("/Imagenes/Add - copia.png")));
        m2.setIcon(new ImageIcon(getClass().getResource("/Imagenes/parametros - copia.png")));
      
        
        
        popup.add(m1);
        popup.add(m2);

        for (Component ellos : pnl_habitaciones.getComponents()) {
            if (ellos instanceof JButton) {
                if (!"19".equals(ellos.getName())) {
                    ((JButton) ellos).setComponentPopupMenu(popup);
                    ellos.addMouseListener(new MouseAdapter() {
                        @Override
                        public void mouseReleased(MouseEvent e) {
                            if (e.isPopupTrigger()) {
                                popup.show(e.getComponent(), e.getX(), e.getY());
                            }
                        }

                        @Override
                        public void mouseClicked(MouseEvent me) {
                            for (Hospedaje_Habitacion unHospedaje : unaHosteria.getAlquileres()) {
                                if (String.valueOf(unHospedaje.getUnaHabitacion().getNumero()).equals(me.getComponent().getName())) {
                                    lbl_huesped.setText(unHospedaje.getUnVisitante().getApellido() + " " + unHospedaje.getUnVisitante().getNombre());
                                    lbl_domicilio.setText(unHospedaje.getUnVisitante().getDireccion().getLocalidad() + ", " + unHospedaje.getUnVisitante().getDireccion().getProvincia() + ", " + unHospedaje.getUnVisitante().getDireccion().getPais());
                                    lbl_in.setText(unHospedaje.getIngreso().toGMTString());
                                    lbl_out.setText(unHospedaje.getEgreso().toString());
                                    lbl_tel_huesped.setText(unHospedaje.getUnVisitante().getTelefono());
                                }
                            }

                        }
                    });

                    ellos.addFocusListener(new FocusListener() {
                        @Override
                        public void focusGained(FocusEvent e) {
                        }

                        @Override
                        public void focusLost(FocusEvent e) {
                            ultimoBoton = ((JButton) e.getComponent());
                        }
                    });
                }
            }
        }

        m1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent ae) {
                JButton elBoton = (JButton) ((JPopupMenu) ((JMenuItem) ae.getSource()).getParent()).getInvoker();
                //ak programo o abro la ventana que quiero y ELBOTON es el que se pasa por parametro

                JDialog frame;
                if (SwingUtilities.getWindowAncestor(pnl_habitaciones) instanceof JDialog) {
                    frame = new JDialog((JDialog) SwingUtilities.getWindowAncestor(pnl_habitaciones), true);
                } else {
                    frame = new JDialog((JFrame) SwingUtilities.getWindowAncestor(pnl_habitaciones), true);
                }
                Check_IN panel_checkin = new Check_IN(unaHosteria, elBoton);
                frame.getContentPane().removeAll();
                frame.getContentPane().add(panel_checkin);
                frame.pack();
                frame.setLocationRelativeTo(null);
                frame.show();
                verificarEstados();



            }
        });
        ;


        m2.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                JButton elBoton = (JButton) ((JPopupMenu) ((JMenuItem) e.getSource()).getParent()).getInvoker();
                //ak programo o abro la ventana que quiero y ELBOTON es el que se pasa por parametro

                JDialog frame;
                if (SwingUtilities.getWindowAncestor(pnl_habitaciones) instanceof JDialog) {
                    frame = new JDialog((JDialog) SwingUtilities.getWindowAncestor(pnl_habitaciones), true);
                } else {
                    frame = new JDialog((JFrame) SwingUtilities.getWindowAncestor(pnl_habitaciones), true);
                }
                Habitacion numeroHab = null;

                for (Habitacion unaHabitacion : unaHosteria.getHabitaciones()) {
                    if (elBoton.getName().equals(String.valueOf(unaHabitacion.getNumero()))) {
                        numeroHab = unaHabitacion;
                    }
                }

                Parametros_Habitacion panel_estados = new Parametros_Habitacion(unaHosteria, numeroHab);
                frame.getContentPane().removeAll();
                frame.getContentPane().add(panel_estados);
                frame.pack();
                frame.setLocationRelativeTo(null);
                frame.show();
                verificarEstados();
            }
        });
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jTextField1 = new javax.swing.JTextField();
        pnl_habitaciones = new javax.swing.JPanel();
        jButton1 = new javax.swing.JButton();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        jButton7 = new javax.swing.JButton();
        jButton8 = new javax.swing.JButton();
        jButton9 = new javax.swing.JButton();
        jButton10 = new javax.swing.JButton();
        jButton11 = new javax.swing.JButton();
        jButton12 = new javax.swing.JButton();
        jButton13 = new javax.swing.JButton();
        jButton14 = new javax.swing.JButton();
        jButton15 = new javax.swing.JButton();
        jButton16 = new javax.swing.JButton();
        jButton17 = new javax.swing.JButton();
        jButton18 = new javax.swing.JButton();
        jButton19 = new javax.swing.JButton();
        panelRect1 = new org.edisoncor.gui.panel.PanelRect();
        btn_abrirLote = new javax.swing.JButton();
        btn_listarCaja = new javax.swing.JButton();
        btn_cerrarLote = new javax.swing.JButton();
        jTextField2 = new javax.swing.JTextField();
        jTextField3 = new javax.swing.JTextField();
        jTextField4 = new javax.swing.JTextField();
        jTextField5 = new javax.swing.JTextField();
        jTextField6 = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        panelCurves1 = new org.edisoncor.gui.panel.PanelCurves();
        jLabel4 = new javax.swing.JLabel();
        lbl_domicilio = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        lbl_huesped = new javax.swing.JLabel();
        lbl_tel_huesped = new javax.swing.JLabel();
        lbl_out = new javax.swing.JLabel();
        lbl_in = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();

        setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.LINE_AXIS));

        jTextField1.setEditable(false);
        jTextField1.setBackground(new java.awt.Color(153, 153, 153));
        jTextField1.setFont(new java.awt.Font("Copperplate Gothic Light", 1, 18)); // NOI18N
        jTextField1.setForeground(new java.awt.Color(255, 255, 255));
        jTextField1.setText("Diario");
        jTextField1.setFocusable(false);

        pnl_habitaciones.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jButton1.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/PCI cards.png"))); // NOI18N
        jButton1.setText("Habitación 01");
        jButton1.setName("1"); // NOI18N

        jButton2.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/PCI cards.png"))); // NOI18N
        jButton2.setText("Habitación 02");
        jButton2.setName("2"); // NOI18N

        jButton3.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jButton3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/PCI cards.png"))); // NOI18N
        jButton3.setText("Habitación 09");
        jButton3.setName("9"); // NOI18N

        jButton4.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jButton4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/PCI cards.png"))); // NOI18N
        jButton4.setText("Habitación 08");
        jButton4.setName("8"); // NOI18N

        jButton5.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/PCI cards.png"))); // NOI18N
        jButton5.setText("Habitación 11");
        jButton5.setName("11"); // NOI18N

        jButton6.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jButton6.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/PCI cards.png"))); // NOI18N
        jButton6.setText("Habitación 10");
        jButton6.setName("10"); // NOI18N

        jButton7.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jButton7.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/PCI cards.png"))); // NOI18N
        jButton7.setText("Habitación 13");
        jButton7.setName("13"); // NOI18N

        jButton8.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jButton8.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/PCI cards.png"))); // NOI18N
        jButton8.setText("Habitación 12");
        jButton8.setName("12"); // NOI18N

        jButton9.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jButton9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/PCI cards.png"))); // NOI18N
        jButton9.setText("Habitación 06");
        jButton9.setName("6"); // NOI18N

        jButton10.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jButton10.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/PCI cards.png"))); // NOI18N
        jButton10.setText("Habitación 14");
        jButton10.setName("14"); // NOI18N

        jButton11.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jButton11.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/PCI cards.png"))); // NOI18N
        jButton11.setText("Habitación 16");
        jButton11.setName("16"); // NOI18N

        jButton12.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jButton12.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/PCI cards.png"))); // NOI18N
        jButton12.setText("Habitación 15");
        jButton12.setName("15"); // NOI18N

        jButton13.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jButton13.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/PCI cards.png"))); // NOI18N
        jButton13.setText("Habitación 07");
        jButton13.setName("7"); // NOI18N

        jButton14.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jButton14.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/PCI cards.png"))); // NOI18N
        jButton14.setText("Habitación 05");
        jButton14.setName("5"); // NOI18N
        jButton14.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton14ActionPerformed(evt);
            }
        });

        jButton15.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jButton15.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/PCI cards.png"))); // NOI18N
        jButton15.setText("Habitación 04");
        jButton15.setName("4"); // NOI18N

        jButton16.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jButton16.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/PCI cards.png"))); // NOI18N
        jButton16.setText("Habitación 03");
        jButton16.setName("3"); // NOI18N
        jButton16.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton16ActionPerformed(evt);
            }
        });

        jButton17.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jButton17.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/PCI cards.png"))); // NOI18N
        jButton17.setText("Habitación 17");
        jButton17.setName("17"); // NOI18N

        jButton18.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jButton18.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/PCI cards.png"))); // NOI18N
        jButton18.setText("Habitación 18");
        jButton18.setName("18"); // NOI18N

        jButton19.setFont(new java.awt.Font("Bookman Old Style", 1, 14)); // NOI18N
        jButton19.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Salon de Eventos.png"))); // NOI18N
        jButton19.setText("Salon de Eventos");
        jButton19.setName("19"); // NOI18N
        jButton19.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton19ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout pnl_habitacionesLayout = new javax.swing.GroupLayout(pnl_habitaciones);
        pnl_habitaciones.setLayout(pnl_habitacionesLayout);
        pnl_habitacionesLayout.setHorizontalGroup(
            pnl_habitacionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnl_habitacionesLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(pnl_habitacionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(pnl_habitacionesLayout.createSequentialGroup()
                        .addGroup(pnl_habitacionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnl_habitacionesLayout.createSequentialGroup()
                                .addComponent(jButton1)
                                .addGap(18, 18, 18)
                                .addComponent(jButton2))
                            .addGroup(pnl_habitacionesLayout.createSequentialGroup()
                                .addComponent(jButton14)
                                .addGap(18, 18, 18)
                                .addComponent(jButton9)))
                        .addGap(18, 18, 18)
                        .addGroup(pnl_habitacionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pnl_habitacionesLayout.createSequentialGroup()
                                .addComponent(jButton16)
                                .addGap(18, 18, 18)
                                .addComponent(jButton15))
                            .addGroup(pnl_habitacionesLayout.createSequentialGroup()
                                .addComponent(jButton13)
                                .addGap(18, 18, 18)
                                .addComponent(jButton4)))
                        .addContainerGap(22, Short.MAX_VALUE))
                    .addGroup(pnl_habitacionesLayout.createSequentialGroup()
                        .addGroup(pnl_habitacionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addGroup(pnl_habitacionesLayout.createSequentialGroup()
                                .addComponent(jButton3)
                                .addGap(18, 18, 18)
                                .addComponent(jButton6)
                                .addGap(18, 18, 18)
                                .addComponent(jButton5)
                                .addGap(18, 18, 18)
                                .addComponent(jButton8))
                            .addGroup(pnl_habitacionesLayout.createSequentialGroup()
                                .addComponent(jButton7)
                                .addGap(18, 18, 18)
                                .addComponent(jButton10)
                                .addGap(18, 18, 18)
                                .addComponent(jButton12)
                                .addGap(18, 18, 18)
                                .addComponent(jButton11))
                            .addGroup(pnl_habitacionesLayout.createSequentialGroup()
                                .addComponent(jButton17)
                                .addGap(18, 18, 18)
                                .addComponent(jButton18)
                                .addGap(18, 18, 18)
                                .addComponent(jButton19, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                        .addGap(0, 0, Short.MAX_VALUE))))
        );
        pnl_habitacionesLayout.setVerticalGroup(
            pnl_habitacionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pnl_habitacionesLayout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(pnl_habitacionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton1)
                    .addComponent(jButton2)
                    .addComponent(jButton16)
                    .addComponent(jButton15))
                .addGap(18, 18, 18)
                .addGroup(pnl_habitacionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton14)
                    .addComponent(jButton9)
                    .addComponent(jButton13)
                    .addComponent(jButton4))
                .addGap(18, 18, 18)
                .addGroup(pnl_habitacionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton3)
                    .addComponent(jButton6)
                    .addComponent(jButton5)
                    .addComponent(jButton8))
                .addGap(18, 18, 18)
                .addGroup(pnl_habitacionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton7)
                    .addComponent(jButton10)
                    .addComponent(jButton12)
                    .addComponent(jButton11))
                .addGap(18, 18, 18)
                .addGroup(pnl_habitacionesLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton17)
                    .addComponent(jButton18)
                    .addComponent(jButton19))
                .addGap(84, 84, 84))
        );

        panelRect1.setBackground(new java.awt.Color(255, 255, 255));
        panelRect1.setForeground(new java.awt.Color(255, 255, 255));
        panelRect1.setColorPrimario(new java.awt.Color(255, 255, 255));
        panelRect1.setColorSecundario(new java.awt.Color(102, 102, 102));
        panelRect1.setPreferredSize(new java.awt.Dimension(150, 184));

        btn_abrirLote.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/Add.png"))); // NOI18N
        btn_abrirLote.setText("      Alquilar");
        btn_abrirLote.setHorizontalAlignment(javax.swing.SwingConstants.LEADING);
        btn_abrirLote.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_abrirLoteActionPerformed(evt);
            }
        });

        btn_listarCaja.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/REAL OSX APPLICATIONS TEXT EDIT.png"))); // NOI18N
        btn_listarCaja.setText("    Listar");
        btn_listarCaja.setHorizontalAlignment(javax.swing.SwingConstants.LEADING);
        btn_listarCaja.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_listarCajaActionPerformed(evt);
            }
        });

        btn_cerrarLote.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/parametros.png"))); // NOI18N
        btn_cerrarLote.setText("<html><p>  Modificar</p><p>  Parámetros</p><html>");
        btn_cerrarLote.setHorizontalAlignment(javax.swing.SwingConstants.LEADING);
        btn_cerrarLote.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btn_cerrarLoteActionPerformed(evt);
            }
        });

        jTextField2.setBackground(new java.awt.Color(255, 0, 0));
        jTextField2.setPreferredSize(new java.awt.Dimension(20, 20));

        jTextField3.setBackground(new java.awt.Color(0, 255, 255));
        jTextField3.setPreferredSize(new java.awt.Dimension(20, 20));

        jTextField4.setBackground(new java.awt.Color(0, 255, 0));
        jTextField4.setPreferredSize(new java.awt.Dimension(20, 20));

        jTextField5.setBackground(new java.awt.Color(255, 175, 175));
        jTextField5.setPreferredSize(new java.awt.Dimension(20, 20));

        jTextField6.setBackground(new java.awt.Color(0, 0, 255));
        jTextField6.setPreferredSize(new java.awt.Dimension(20, 20));

        jLabel7.setText("Ocupada");

        jLabel8.setText("Disponible");

        jLabel9.setText("Sale Hoy");

        jLabel10.setText("Sale Mañana");

        jLabel11.setText("Falta Limpiar");

        javax.swing.GroupLayout panelRect1Layout = new javax.swing.GroupLayout(panelRect1);
        panelRect1.setLayout(panelRect1Layout);
        panelRect1Layout.setHorizontalGroup(
            panelRect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelRect1Layout.createSequentialGroup()
                .addGap(15, 15, 15)
                .addGroup(panelRect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelRect1Layout.createSequentialGroup()
                        .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel11))
                    .addGroup(panelRect1Layout.createSequentialGroup()
                        .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel10))
                    .addGroup(panelRect1Layout.createSequentialGroup()
                        .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel9))
                    .addGroup(panelRect1Layout.createSequentialGroup()
                        .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel8))
                    .addGroup(panelRect1Layout.createSequentialGroup()
                        .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel7))
                    .addGroup(panelRect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                        .addComponent(btn_cerrarLote, javax.swing.GroupLayout.Alignment.LEADING)
                        .addComponent(btn_abrirLote, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btn_listarCaja, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
                .addContainerGap(18, Short.MAX_VALUE))
        );
        panelRect1Layout.setVerticalGroup(
            panelRect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelRect1Layout.createSequentialGroup()
                .addGap(14, 14, 14)
                .addComponent(btn_abrirLote)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(btn_cerrarLote, javax.swing.GroupLayout.PREFERRED_SIZE, 44, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(btn_listarCaja)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(panelRect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel7))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelRect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelRect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel9))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelRect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel10))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelRect1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel11))
                .addGap(19, 19, 19))
        );

        jLabel4.setFont(new java.awt.Font("Bell MT", 3, 14)); // NOI18N
        jLabel4.setText("Domicilio:");

        lbl_domicilio.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jLabel3.setFont(new java.awt.Font("Bell MT", 3, 14)); // NOI18N
        jLabel3.setText("Teléfono:");

        jLabel1.setFont(new java.awt.Font("Bell MT", 3, 14)); // NOI18N
        jLabel1.setText("Huesped:");

        lbl_huesped.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        lbl_tel_huesped.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        lbl_out.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        lbl_in.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

        jLabel5.setFont(new java.awt.Font("Bell MT", 3, 14)); // NOI18N
        jLabel5.setText("IN:");

        jLabel6.setFont(new java.awt.Font("Bell MT", 3, 14)); // NOI18N
        jLabel6.setText("OUT:");

        javax.swing.GroupLayout panelCurves1Layout = new javax.swing.GroupLayout(panelCurves1);
        panelCurves1.setLayout(panelCurves1Layout);
        panelCurves1Layout.setHorizontalGroup(
            panelCurves1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelCurves1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelCurves1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelCurves1Layout.createSequentialGroup()
                        .addGroup(panelCurves1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel4)
                            .addComponent(jLabel1))
                        .addGap(11, 11, 11))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelCurves1Layout.createSequentialGroup()
                        .addComponent(jLabel3)
                        .addGap(18, 18, 18)))
                .addGroup(panelCurves1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(panelCurves1Layout.createSequentialGroup()
                        .addGroup(panelCurves1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(lbl_tel_huesped, javax.swing.GroupLayout.PREFERRED_SIZE, 208, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lbl_huesped, javax.swing.GroupLayout.PREFERRED_SIZE, 208, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(36, 36, 36)
                        .addGroup(panelCurves1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel6, javax.swing.GroupLayout.Alignment.TRAILING))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelCurves1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(lbl_in, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(lbl_out, javax.swing.GroupLayout.PREFERRED_SIZE, 118, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addComponent(lbl_domicilio, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(479, Short.MAX_VALUE))
        );
        panelCurves1Layout.setVerticalGroup(
            panelCurves1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelCurves1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelCurves1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelCurves1Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addGroup(panelCurves1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbl_in, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel5))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelCurves1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbl_out, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel6)))
                    .addGroup(panelCurves1Layout.createSequentialGroup()
                        .addGroup(panelCurves1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbl_huesped, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel1))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelCurves1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(lbl_tel_huesped, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelCurves1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(lbl_domicilio, javax.swing.GroupLayout.PREFERRED_SIZE, 26, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4))
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTextField1)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
                        .addComponent(pnl_habitaciones, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(panelRect1, javax.swing.GroupLayout.DEFAULT_SIZE, 162, Short.MAX_VALUE))
                    .addComponent(panelCurves1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(pnl_habitaciones, javax.swing.GroupLayout.PREFERRED_SIZE, 386, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(panelRect1, javax.swing.GroupLayout.DEFAULT_SIZE, 386, Short.MAX_VALUE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(panelCurves1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        add(jPanel1);
    }// </editor-fold>//GEN-END:initComponents

    private void jButton16ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton16ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton16ActionPerformed

    private void jButton14ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton14ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jButton14ActionPerformed

    private void btn_listarCajaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_listarCajaActionPerformed
        try {
            generarReporte();
        } catch (SQLException ex) {
//            Logger.getLogger(Vista_Diario.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_btn_listarCajaActionPerformed

    private void btn_abrirLoteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_abrirLoteActionPerformed
        JDialog frame;
        if (SwingUtilities.getWindowAncestor(pnl_habitaciones) instanceof JDialog) {
            frame = new JDialog((JDialog) SwingUtilities.getWindowAncestor(pnl_habitaciones), true);
        } else {
            frame = new JDialog((JFrame) SwingUtilities.getWindowAncestor(pnl_habitaciones), true);
        }


        Check_IN panel_checkin = new Check_IN(unaHosteria, ultimoBoton);
        frame.getContentPane().removeAll();
        frame.getContentPane().add(panel_checkin);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.show();
        verificarEstados();
    }//GEN-LAST:event_btn_abrirLoteActionPerformed

    private void btn_cerrarLoteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_cerrarLoteActionPerformed
        JDialog frame;
        if (SwingUtilities.getWindowAncestor(this) instanceof JDialog) {
            frame = new JDialog((JDialog) SwingUtilities.getWindowAncestor(this), true);
        } else {
            frame = new JDialog((JFrame) SwingUtilities.getWindowAncestor(this), true);
        }
        Parametros_Habitacion losEstados = new Parametros_Habitacion(unaHosteria, null);
        frame.getContentPane().removeAll();
        frame.getContentPane().add(losEstados);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.show();
        verificarEstados();
    }//GEN-LAST:event_btn_cerrarLoteActionPerformed

    private void jButton19ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton19ActionPerformed
        JPanel unPanel = (JPanel) this.getParent();
        Salon_de_Eventos elSalon_de_Eventos = new Salon_de_Eventos(unaHosteria);
        unPanel.removeAll();
        unPanel.add(elSalon_de_Eventos);
        unPanel.updateUI();
    }//GEN-LAST:event_jButton19ActionPerformed

    public void generarReporte() throws SQLException {
        SwingUtilities.getWindowAncestor(this).dispose();
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btn_abrirLote;
    private javax.swing.JButton btn_cerrarLote;
    private javax.swing.JButton btn_listarCaja;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton10;
    private javax.swing.JButton jButton11;
    private javax.swing.JButton jButton12;
    private javax.swing.JButton jButton13;
    private javax.swing.JButton jButton14;
    private javax.swing.JButton jButton15;
    private javax.swing.JButton jButton16;
    private javax.swing.JButton jButton17;
    private javax.swing.JButton jButton18;
    private javax.swing.JButton jButton19;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JButton jButton8;
    private javax.swing.JButton jButton9;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JLabel lbl_domicilio;
    private javax.swing.JLabel lbl_huesped;
    private javax.swing.JLabel lbl_in;
    private javax.swing.JLabel lbl_out;
    private javax.swing.JLabel lbl_tel_huesped;
    private org.edisoncor.gui.panel.PanelCurves panelCurves1;
    private org.edisoncor.gui.panel.PanelRect panelRect1;
    private javax.swing.JPanel pnl_habitaciones;
    // End of variables declaration//GEN-END:variables

    private void verificarEstados() {

        for (Component losBotones : pnl_habitaciones.getComponents()) {
            losBotones.setBackground(Color.GREEN);
        }
        for (Habitacion unaHabitacion : unaHosteria.getHabitaciones()) {
            if (!unaHabitacion.isHabilitado()) {
                for (Component losBotones : pnl_habitaciones.getComponents()) {
                    if (losBotones.getName().equals(String.valueOf(unaHabitacion.getNumero()))) {
                        losBotones.setBackground(Color.gray);
                        break;
                    }
                }
            } else if (!unaHabitacion.isEstado_limpieza()) {
                for (Component losBotones : pnl_habitaciones.getComponents()) {
                    if (losBotones.getName().equals(String.valueOf(unaHabitacion.getNumero()))) {
                        losBotones.setBackground(Color.pink);
                        break;
                    }

                }
            }


            for (Hospedaje_Habitacion unHospedaje : unaHosteria.getAlquileres()) {
                if (!unHospedaje.isCheck_out()) {
                    Calendar sale = Calendar.getInstance();
                    sale.setTime(unHospedaje.getEgreso());

                    Calendar hoy = Calendar.getInstance();
                    hoy.setTime(new Date());

                    Calendar mañana = Calendar.getInstance();
                    mañana.add(Calendar.DAY_OF_MONTH, 1);
                    for (Component losBotones : pnl_habitaciones.getComponents()) {

                        if (!(String.valueOf(unHospedaje.getUnaHabitacion().getNumero()).equals(losBotones.getName()))) {
                        } else {
                            losBotones.setForeground(Color.white);
                            if (sale.get(Calendar.DAY_OF_YEAR) > (mañana.get(Calendar.DAY_OF_YEAR))) {
                                losBotones.setBackground(Color.red);
                            }
                            if (sale.get(Calendar.DAY_OF_YEAR) == (mañana.get(Calendar.DAY_OF_YEAR))) {
                                losBotones.setBackground(Color.BLUE);
                            }
                            if (sale.get(Calendar.DAY_OF_YEAR) == (hoy.get(Calendar.DAY_OF_YEAR))) {
                                losBotones.setBackground(Color.CYAN);
                            }

                        }
                    }
                }
            }

        }
    }
}
